﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ITAnimationController : MonoBehaviour
{
    private Animator _animator;

    [SerializeField]
    private bool _isDying;

    private float _coroutineTime = 0.5f;

    private void Start()
    {
        _animator = GetComponent<Animator>();
        StartCoroutine(HandleChangeAnimationState());
    }

    private void Update()
    {
    }

    public void SetDyingState(bool isDying)
    {
        _isDying = isDying;
    }

    private IEnumerator HandleChangeAnimationState()
    {
        while (true)
        {
            yield return new WaitForSeconds(_coroutineTime);
            _animator.SetBool("IsDying", _isDying);
            if (GameFlowManager.Instance.IsITDead())
            {
                _animator.SetTrigger("Dead");
            }
        }
    }
}
